/* OutSubViewDao.java
 *
 * Project/Product: GWBS2009
 *
 * Modify Information:
 * =============================================================================
 *   Author	Date       Description
 *   ----------	---------- ---------------------------------------------------
 *   apep	2010-3-31	First release
 *
 * Licensed Materials - Property of APEP
 * =============================================================================
 *    (C) COPYRIGHT Shanghai Auto Mart E-Procurement Co., Ltd. 2007 - 2010
 *    All Rights Reserved.
 *
 *    This software is the confidential and proprietary information of
 *    Shanghai Auto Mart E-Procurement Co., Ltd. ("Confidential Information").
 *    You shall not disclose such Confidential Information and shall use it only
 *    in accordance with the terms of the license agreement you entered into 
 *    with Shanghai Auto Mart E-Procurement Co., Ltd.
 *
 * Noties:
 * =============================================================================
 * 
 */

package com.apep.jwcs.dao;

import java.sql.SQLException;
import java.util.List;

import com.apep.jwcs.pojo.OutSubView;
import com.hitrust.gs.lib.GSLogWriter;
import com.hitrust.gs.lib.db.GSBaseDAO;
import com.hitrust.gs.util.exception.GSException;

public class OutSubViewDao extends GSBaseDAO{
    
    
    public List findOutSubView(String startTime,String endTime,String warehouseCode) throws GSException{
        String sql=" select   pcategory.Name,product.PRODUCT_BRAND,outSub.PRODUCT_MONEY, outHead.OUT_TIME, busInfo.BUS_USE_DATE  "+
        		   " from T_OUT_SUB outSub left join T_OUT_HEAD outHead on outSub.OUT_BILL_ID = outHead.ID "+
                   " left join T_BUS_INFO busInfo on busInfo.BUS_CODE = outHead.CUSTOMER_BUS_CODE "+
                   " left join T_PRODUCT product on outSub.PRODUCT_ID = product.id "+
                   " left join T_PRODUCT_CATEGORY pcategory on product.CATEGORY_CODE = pcategory.CODE "+
                   " where outSub.STATUS=1 and outHead.REPAIR_BILL_CODE is not null and outHead.REPAIR_BILL_CODE <>' ' and  outHead.CUSTOMER_BUS_CODE is not null and outHead.CUSTOMER_BUS_CODE <> ' ' "+
                   " and (pcategory.Name='五大类' or pcategory.Name='非五大类' or pcategory.Name='易损件') "+
                   "and busInfo.WAREHOUSE_CODE  like '"+warehouseCode+"%' and outHead.WAREHOUSE_CODE like '"+warehouseCode+"%' "+
                   "and outHead.OUT_TIME >? and outHead.OUT_TIME <?";
       List list=null;
       Object[] obj={startTime,endTime};
       try {
        list=executeQuery(new OutSubView(), sql, obj);
        } catch (Exception e) {
            GSLogWriter.error(this,e.toString());
            e.printStackTrace();
            throw new GSException(GSException.E10040, GSException.E10040_MSG);     
        }
       return list;
    }
}
